home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
QUI
/
UTI
/
Premier Plug-In Kit 1.0.cpt
/
Premier Plug-In Kit 1.0
/
MPW Examples
/
.c
/
Wipe.c
< prev
next >
Wrap
Text File
|
1992-03-04
|
3KB
|
103 lines
//———————————————————————————————————————————————
//
// ©1991 Adobe Systems Inc.
// written by Randy Ubillos
//
//———————————————————————————————————————————————
// This is a general purpose routine which can be used to create any
// type of effect where the effect shape can be described in a region.
// Simply replace your region generator between the OpenRgn() and
// CloseRgn() calls, and the framework will handle the rest...
// Load in your Mac headers here
#pragma load "headers.d"
#include "Interface-Effect.h"
//———————————————————————————————————————————————
// Perform the effect
pascal short xEffect(short selector, EffectHandle theData)
{
short result = 0,width,height,spot,hpart,vpart;
Rect fullbox,partbox;
RgnHandle rgn1,rgn2;
switch (selector) {
case esExecute:
rgn1 = NewRgn(); // make 2 regions
rgn2 = NewRgn();
fullbox = partbox = ((GrafPtr)(*theData)->destination)->portRect; // get the bounds
width = fullbox.right - fullbox.left; // calc width
height = fullbox.bottom - fullbox.top; // calc height
spot = (*theData)->part * (height+width) / (*theData)->total; // what percentage?
hpart = (*theData)->part * width / (*theData)->total; // horiz percent
vpart = (*theData)->part * height / (*theData)->total; // vert percent
OpenRgn(); // make a region
// outline it's shape here
switch ((*theData)->arrowFlags) {
case bitUpperRight:
MoveTo(fullbox.right,fullbox.top);
LineTo(fullbox.right-spot,fullbox.top);
LineTo(fullbox.right,fullbox.top+spot);
LineTo(fullbox.right,fullbox.top);
break;
case bitLowerRight:
MoveTo(fullbox.right,fullbox.bottom);
LineTo(fullbox.right-spot,fullbox.bottom);
LineTo(fullbox.right,fullbox.bottom-spot);
LineTo(fullbox.right,fullbox.bottom);
break;
case bitLowerLeft:
MoveTo(fullbox.left,fullbox.bottom);
LineTo(fullbox.left+spot,fullbox.bottom);
LineTo(fullbox.left,fullbox.bottom-spot);
LineTo(fullbox.left,fullbox.bottom);
break;
case bitUpperLeft:
MoveTo(fullbox.left,fullbox.top);
LineTo(fullbox.left+spot,fullbox.top);
LineTo(fullbox.left,fullbox.top+spot);
LineTo(fullbox.left,fullbox.top);
break;
case bitTop:
partbox.bottom = partbox.top + vpart;
FrameRect(&partbox);
break;
case bitRight:
partbox.left = partbox.right - hpart;
FrameRect(&partbox);
break;
case bitBottom:
partbox.top = partbox.bottom - vpart;
FrameRect(&partbox);
break;
default:
partbox.right = partbox.left + hpart;
FrameRect(&partbox);
break;
}
CloseRgn(rgn1); // close the region
RectRgn(rgn2,&fullbox);
SectRgn(rgn2,rgn1,rgn1); // limit to bounds
DiffRgn(rgn2,rgn1,rgn2); // find opposite rgn
CopyBits((BitMap*)&(*theData)->source1->portPixMap, // copy useful part of
(BitMap*)&(*theData)->destination->portPixMap, // src 2
&fullbox,&fullbox,srcCopy,rgn2);
CopyBits((BitMap*)&(*theData)->source2->portPixMap, // copy useful part of
(BitMap*)&(*theData)->destination->portPixMap, // src 1
&fullbox,&fullbox,srcCopy,rgn1);
DisposeRgn(rgn1);
DisposeRgn(rgn2); // kill the regions
break;
case esSetup: // we don't do any setup
break;
}
return(result);
}